<?php
/**
 * Created by PhpStorm.
 * User: colin
 * Date: 15-3-29
 * Time: 23:50
 */

namespace common\models\myhtsq;

use common\models\BaseModel;

class ContractManageModel extends BaseModel
{

    public $customer_property;
    public $contract_property;
    public $draw_project_numeric;
    public $balance_type;
    public $balance_status;
    public $contract_status;
    public $sign_date;
    public $input_date;
    public $back_date;
    public $review_date;
    public $created_on;
    public $modified_on;
    public $contract_id;
    public $customer_id;
    public $customer_code;
    public $company_id;
    public $area_id;
    public $category_id;
    public $littler_category_id;
    public $sign_people_id;
    public $sign_people_department_id;
    public $account_company_id;
    public $reviewer_id;
    public $customer_name;
    public $top_customer_name;
    public $contract_code;
    public $contract_category;
    public $balance_remark;
    public $is_violated;
    public $sign_amount;
    public $rent_amount;
    public $delivery_amount;
    public $application_amount;
    public $application_deal_amount;
    public $application_deal_discount;
    public $contract_deal_discount;
    public $balance_rate;
    public $balance_amount;
    public $back_amount;
    public $customer_full_name;
    public $modified_by;
    public $created_by;
    public $is_cancelled;
    public $big_category_id;
    public $contract_property_id;
    public $give_work_day;
    public $develop_work_day;
    public $implement_work_day;
    public $effect_date;
    public $income_amount;
    public $project_numeric;
    public $contract_remark;
    public $achievement_remark;
    public $erp_contract_id;
    public $erp_contract_code;
    public $balance_should_amount;
    public $business_type_id;
    public $supplier_id;
    public $soure_financial;
    public $soure_business;

    public function __construct($config = [])
    {
        parent::__construct($config);
    }

    public function rules()
    {
        return [
            //新增合同
            [['is_violated', 'customer_property', 'contract_property', 'draw_project_numeric', 'balance_type', 'balance_status', 'contract_status', 'project_numeric'], 'integer', 'on' => 'add'],
            [['effect_date','sign_date', 'input_date', 'back_date', 'review_date', 'created_on', 'modified_on'], 'safe', 'on' => 'add'],
            [['contract_id','erp_contract_id', 'customer_id','business_type_id', 'customer_code', 'company_id', 'area_id', 'category_id', 'littler_category_id', 'big_category_id', 'contract_property_id', 'sign_people_id', 'sign_people_department_id','account_company_id', 'reviewer_id', 'created_by', 'modified_by'], 'string', 'max' => 36, 'on' => 'add'],
            [['customer_name', 'top_customer_name', 'contract_code', 'contract_category'], 'string', 'max' => 200, 'on' => 'add'],
            [['balance_remark', 'contract_remark', 'achievement_remark','erp_contract_code','soure_financial','soure_business'], 'string', 'on' => 'add'],
            [['sign_amount','balance_should_amount', 'rent_amount', 'delivery_amount', 'application_amount', 'application_deal_amount', 'application_deal_discount', 'contract_deal_discount', 'balance_rate', 'balance_amount', 'back_amount', 'implement_work_day', 'develop_work_day', 'give_work_day', 'income_amount'], 'number', 'on' => 'add'],
            [['customer_full_name'], 'string', 'max' => 100, 'on' => 'add'],
            ['is_cancelled', 'default', 'value' => 0],//是否作废
            ['contract_status', 'default', 'value' => 0],//合同状态
            ['is_violated', 'default', 'value' => 0],//是否违规合同
            ['balance_status', 'default', 'value' => 0],//是否结算
            ['balance_type', 'default', 'value' => 0],//结算类型
            ['draw_project_numeric', 'default', 'value' => 0],//提成项目数
            ['contract_property_id', 'default', 'value' => 0],//合同性质id
            ['business_type_id', 'default', 'value' => 0],//合同性质id
            ['customer_property', 'default', 'value' => 0],//客户性质
            ['implement_work_day', 'default', 'value' => 0],//实施工作量天数
            ['develop_work_day', 'default', 'value' => 0],//开发工作量天数
            ['give_work_day', 'default', 'value' => 0],//赠送工作量天数

            //更新合同
            [['is_violated', 'customer_property', 'contract_property', 'draw_project_numeric', 'balance_type', 'balance_status', 'contract_status', 'project_numeric'], 'integer', 'on' => 'update'],
            [['effect_date','sign_date', 'input_date', 'back_date', 'review_date', 'created_on', 'modified_on'], 'safe', 'on' => 'update'],
            [['contract_id','erp_contract_id', 'customer_id','business_type_id', 'company_id', 'area_id', 'category_id', 'littler_category_id', 'big_category_id', 'contract_property_id', 'sign_people_id','sign_people_department_id', 'account_company_id', 'reviewer_id', 'created_by', 'modified_by'], 'string', 'max' => 36, 'on' => 'update'],
            [['customer_name', 'top_customer_name', 'contract_code', 'customer_code', 'contract_category'], 'string', 'max' => 200, 'on' => 'update'],
            [['balance_remark'], 'string', 'on' => 'update'],
            [['sign_amount','balance_should_amount', 'rent_amount', 'delivery_amount', 'application_amount', 'application_deal_amount', 'application_deal_discount', 'contract_deal_discount', 'balance_rate', 'balance_amount', 'back_amount', 'develop_work_day', 'give_work_day', 'implement_work_day', 'income_amount'], 'number', 'on' => 'update'],
            [['customer_full_name','soure_financial','soure_business'], 'string', 'max' => 100, 'on' => 'update'],
            [['erp_contract_code'], 'string', 'max' => 200, 'on' => 'update'],
            [['contract_remark', 'achievement_remark'], 'string', 'max' => 500, 'on' => 'update'],
        ];
    }
}